package com.manbu.live.user.provider.rpc;

import com.alibaba.nacos.client.naming.utils.CollectionUtils;
import com.manbu.live.farmework.redis.starter.keys.UserProviderCacheKeyBuilder;
import com.manbu.live.id.generate.interfaces.IdGenerateRpc;
import com.manbu.live.user.dto.UserDTO;
import com.manbu.live.user.dto.UserLoginDTO;
import com.manbu.live.user.dto.UserPhoneDTO;
import com.manbu.live.user.inerface.IUserPhoneRpc;
import com.manbu.live.user.provider.service.IUserPhoneService;
import com.manbu.live.user.provider.service.IUserService;
import jakarta.annotation.Resource;
import org.apache.dubbo.config.annotation.DubboReference;
import org.apache.dubbo.config.annotation.DubboService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.data.redis.core.RedisTemplate;

import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.UUID;
import java.util.concurrent.TimeUnit;

/**
 * @author hanWang
 * @Title:
 * @Package
 * @Description:
 * @date 2024/1/282:45 AM
 */
@DubboService
public class UserPhoneRpcImpl implements IUserPhoneRpc {
    private static final Logger LOGGER = LoggerFactory.getLogger(UserPhoneRpcImpl.class);
    @Resource
    private IUserPhoneService userPhoneService;
//    @Resource
//    private IUserService userService;
//    @DubboReference
//    private IdGenerateRpc idGenerateRpc;
//    @Resource
//    private RedisTemplate<String, UserPhoneDTO> redisTemplate;
//    @Resource
//    private RedisTemplate<String, Object> stringObjectRedisTemplate;
//    @Resource
//    private UserProviderCacheKeyBuilder cacheKeyBuilder;

    @Override
    public UserLoginDTO login(String phone) {
        if (phone == null) {
            return UserLoginDTO.loginError("手机号不能为空");
        }
        return userPhoneService.login(phone);

    }

    @Override
    public List<UserPhoneDTO> queryByUserId(Long userId) {
        return userPhoneService.queryByUserId(userId);
    }

    @Override
    public UserPhoneDTO queryByPhone(String phone) {
        return userPhoneService.queryByPhone(phone);
    }

}